package src.com.test.twoDay;

<<<<<<< HEAD
public class demo1 {
}
=======
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class demo1 {
    public static void main(String[] args) {

        System.out.println(isReserver("cabdbad",1,5));

    }

    List<List<String>> res = new ArrayList<>();
    LinkedList<String> path = new LinkedList<>();


    public List<List<String>> partition(String s) {
        tracebacking(s,0);
        return res;
    }

    public void tracebacking(String s,int index){

        if(index >= s.length()){
            res.add(new ArrayList<>(path));
            return;
        }

        for(int i = index;i < s.length();i++){
            if(isReserver(s,index,i)){
                String str = s.substring(index,i - index + 1);
                path.add(str);
            }else {
                continue;
            }
            tracebacking(s,i+1);
            path.removeLast();
        }
    }

    public static boolean isReserver(String s,int start,int end){

        for(int i = start;i <= (end + start) / 2;i ++){

            if(s.charAt(i) != s.charAt(start + end - i)){
                return false;
            }
        }
        return true;
    }
}
>>>>>>> e3d7b27ea55ee27ed4cc6990a1e265e8890f50d6
